package com.llz.leaveApply.controller;



import com.llz.leaveApply.dto.Result;
import com.llz.leaveApply.service.FileService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

@RestController
@RequestMapping("/upload")
@CrossOrigin
public class OssController {


    @Autowired
    FileService fileService;

    /**
     * 上传文件 储存到阿里云的oss中 然后返回其网络地址
     */
    @PostMapping
    public Result uploadOssFile(@RequestBody MultipartFile file) {
       String priex= file.getOriginalFilename().substring(0,2);
        switch (priex){
            case "健康":
                System.out.println("健康");

                break;
                case "行程":
                System.out.println("行程" );
                break;
                case "核酸":
                System.out.println("核酸");
                break;


        }
          String url=  fileService.uploadAvator(file);
        return Result.ok2(url);
    }


}
